You should also have a myfile.close(); statement in there after you have finished using the file.
The system will usually automatically close any open files when the program exits, but it's good practice to explicitly close files. (Loss of data and other problems may occur when files aren't properly closed).