This may be a dumb question, but you mentioned: There's definitely not a problem opening input_sequence.txt, because this is used successfully elsewhere in the program. Did you forget to close the filehandle to input_sequence.txt or leave it (f)locked? I've been bitten by dumb mistakes like that before.