You have a few problems...
First, when you open a file you need to use with
, this will handle closing your file for you.
Now, when you read each line in turn you are returning the first one. That returns from the whole function so is not what you want. I take it you want to append each item onto your list.
Also, your functions are better made generic. Pass in the filename and the data. Get them outside the function for more flexibility.
It is not clear what you want to do here. I have assumed you want to specify values to add to a list which is persisted in a file. There are better ways to do this. This is my attempt based on your original code.
def readFile(ui):
L = []
with open(ui, 'r') as f:
for line in f.readlines():
L.append(float(line))
return sorted(L)
def fileAddValue(ui, val):
with open(ui, 'a') as f:
f.write(str(val) + '\n')
ui = raw_input("Please enter your file name:")
L = readFile(ui)
print('original file:')
print(L)
val = float(raw_input("Enter the value you would like to add to the list: "))
fileAddValue(ui, val)
L = readFile(ui)
print('updated file:')
print(L)